<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        #container {
            width: 600px;
            height: 150px;
            margin: 20px auto;
            background-color: #ccc;
            position: relative;
        }

        ul {
            list-style: none;
            height: 90px;

        }

        .first {
            position: absolute;
            left: 0px;
            top: 50px;
        }

        .second {
            position: absolute;
            right: 0px;
            top: 50px;
        }

        .first>li {
            height: 80px;
            width: 80px;
            line-height: 80px;
            text-align: center;
            border-radius: 50%;
            background-color: #f00;
            float: left;

        }

        .second>li {
            height: 80px;
            width: 80px;
            line-height: 80px;
            text-align: center;
            border-radius: 50%;
            background-color: blue;
            float: left;

        }

        button {
            width: 100px;
            height: 50px;
        }
    </style>
</head>

<body>
    <div id="container">
        <ul class="first">
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
        <ul class="second">
            <li></li>
        </ul>
        <button>按钮</button>
    </div>

    <script>
        let lis = document.querySelectorAll('.first>li');
        let secondLi = document.querySelector('.second>li');
        let btn = document.querySelector('button');
        let redArr = [];
        let blueArr = [];

        for (let i = 0; i < 34; i++) {
            if (i < 17) {
                blueArr.push(i);
            }
            redArr.push(i);

        }
        console.log(redArr);
        console.log(blueArr);
        let b = 45;

        let randomIndex = param => Math.floor(Math.random() * param);


        for (let i = 0; i < lis.length; i++) {
            let redIndex = redArr.splice(randomIndex(redArr.length), 1)[0];
            lis[i].innerText = redIndex;
        }
        secondLi.innerText = blueArr[randomIndex(blueArr.length)];

        btn.onclick = () => {
            redArr = [];
            blueArr = [];
            for (let i = 0; i < 34; i++) {
                if (i < 17) {
                    blueArr.push(i);
                }
                redArr.push(i);

            }
            
            for (let i = 0; i < lis.length; i++) {
                let redIndex = redArr.splice(randomIndex(redArr.length), 1)[0];
                lis[i].innerText = redIndex;
            }
            secondLi.innerText = blueArr[randomIndex(blueArr.length)];


        }



    </script>
</body>

</html>